using System;
using System.Collections;
using System.Configuration;
using Iivil.Infrastructure;

namespace Iivil.Infrastructure.Configuration.Providers {
	/// <summary>
	/// Summary description for AppConfig.
	/// </summary>
	public class AppConfig : IConfigurationProvider{
		System.Configuration.AppSettingsReader _reader;
        Hashtable _cache;
		public AppConfig() {
			_reader = new AppSettingsReader();
            _cache = new Hashtable();
			//
			// TODO: Add constructor logic here
			//
		}

		public string GetString(string name) {
			try {
                if (!_cache.ContainsKey(name))
    				_cache[name] = (string)_reader.GetValue(name, typeof(string));
                return (string)_cache[name];
			} catch (Exception e) {
				System.Diagnostics.Debug.WriteLine(e.Message);
			}
			return "";
		}

		public int GetInt(string name) {
			return (int)_reader.GetValue(name, typeof(int));
		}

		public bool ReadOnly {
			get { return true; }
		}

	}
}
